/**
 * 
 */
package test;

import hephaestus.model.metamodel.Attribute;
import hephaestus.model.metamodel.Classe;
import hephaestus.model.metamodel.Method;
import hephaestus.model.metamodel.Model;
import hephaestus.model.metamodel.Package;
import hephaestus.model.metamodel.Parameter;
import hephaestus.model.transformer.NewCodeTransformer;
import hephaestus.model.transformer.Transformer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * @author $Leandro$
 * 
 */
public class TransformationTestV2 {

	private Model model;

	/**
	 * @throws java.lang.Exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		model = new Model();
		model.setType(".java");

		Package pDao = new Package();

		Classe c = new Classe("ClasseDeTeste");
		c.setStereotype("model");
		c.setPackageName(pDao.getName());

		Collection atrList = new ArrayList();

		Attribute atr = new Attribute("a", "Integer");
		atr.setVisibility("private");

		atrList.add(atr);

		Method m = new Method("metodo1","Integer");
		m.setVisibility("public");		

		Parameter param1 = new Parameter("p1", "String");
		Parameter param2 = new Parameter("p2", "Integer");

		Collection paramList = new ArrayList();
		paramList.add(param1);
		paramList.add(param2);

		m.setParameters(paramList);

		Collection mList = new ArrayList();

		mList.add(m);

		atrList = new ArrayList();

		atr = new Attribute("a", "Integer");
		atr.setVisibility("private");

		atrList.add(atr);

		m = new Method("metodo1","void");
		m.setVisibility("public");
		m.setType("void");

		param1 = new Parameter("p1", "String");
		param2 = new Parameter("p2", "Integer");

		paramList = new ArrayList();
		paramList.add(param1);
		paramList.add(param2);

		m.setParameters(paramList);

		mList = new ArrayList();

		mList.add(m);

		Collection cListDao = new ArrayList();
		cListDao.add(c);

		pDao.setClasses(cListDao);

		Collection pList = new ArrayList();
		pList.add(pDao);

		model.setPackages(pList);
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Test method for {@link transformer.CodeTransformer#transform()}.
	 */
	@Test
	public final void testTransform() {
		Map<String, String> m = new HashMap<String, String>();
		m.put("transformationType", "java");
		m.put("appPath", "gerado");

		model.setProjectName("teste_hephaestus");

		Transformer t = new NewCodeTransformer(m);
		t.setModel(model);

		assert true;
		try {
			t.transform();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}